<template>
  <div class="hello">
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            icon="el-icon-edit"
            @click="handleEdit(scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            icon="el-icon-delete-solid"
            @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :current-page="currentPage"
      :page-size="pageSize"
      @current-change="chengPage"
      :total="totals">
    </el-pagination>

  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      currentPage:1,
      pageSize:5,
      totals:10
    }
  },
  methods:{
    chengPage(r){
      this.currentPage=r
      this.getStu()
    },
    handleDelete(row){
      console.log(row)
    },
    handleEdit(row){
      console.log(row)
    },
    getStu(){
      this.$http.post("/stu/list",{"currentPage":this.currentPage,"pageSize":this.pageSize}).then(r=>{
        this.tableData=r.data.data;
          this.totals=r.data.totals
      }).catch(r=>{

      })
    }
  },
  mounted(){
    this.getStu()
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>


</style>
